package com.example.controller;

import com.example.dao.DeptDao;
import com.example.entity.Dept;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("dept")
public class DeptController {
    @Resource
    DeptDao deptDao;
    @RequestMapping("select")
    public String select(Model model){
        List<Dept> list=deptDao.select();
        model.addAttribute("list",list);
        return "forward:/deptList.jsp";
    }
    @RequestMapping("select1")
    public String select1(Model model,Dept dept){
        List<Dept> list=deptDao.select1(dept);
        model.addAttribute("list",list);
        return "forward:/deptList.jsp";
    }
    @RequestMapping("add")
    public String add(Dept dept){
        int result=deptDao.add(dept);
        return "redirect:/dept/select";
    }
}
